class Solution {
    public String mergeAlternately(String word1, String word2) {
        int i=0;
        int j=0;
        StringBuffer buff=new StringBuffer();
        int s1=word1.length();
        int s2=word2.length();
        while(i<s1||j<s2)
        {
            if(i<s1){
            buff.append(word1.charAt(i));
            i++;
            }
            if(j<s2)
            {
                buff.append(word2.charAt(j));
                j++;
            }
        }
        return buff.toString();
    }
}
